package com.example.clublesson01.web

import android.os.Bundle
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.kf.lib_base.base.BaseViewActivity
import com.example.clublesson01.R
import com.example.clublesson01.databinding.ActivityWebBinding

@Route(path = "/app/web/WebActivity")

class WebActivity : BaseViewActivity<ActivityWebBinding>() {
    @Autowired
    @JvmField
    var url=""
    override fun iniView() {
        ARouter.getInstance().inject(this)
        val url = intent.extras?.getString("url")
        if (url != null) {
            binding.web.loadUrl(url)
            binding.web.webViewClient= WebViewClient()
            val webChromeClient=object : WebChromeClient(){
                override fun onProgressChanged(view: WebView?, newProgress: Int) {
                    super.onProgressChanged(view, newProgress)
                    if(newProgress==100){
                        binding.pro.isVisible=false
                    }else{
                        binding.pro.isVisible=true
                    }
                }
            }
            binding.web.webChromeClient=webChromeClient
        }
    }

    override fun iniData() {

    }

    override fun Layoutid(): Int {
        return R.layout.activity_web
    }
}